﻿    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EzDesk.Core.Model;

namespace EzDesk.Core.Interface
{
    public interface ICoreAppService
    {
        #region [ Globle Info ]
        Organization GetOrganizationInfo();
        #endregion

        #region [ UserInfos ]
        UserProfile GetUserProfileById(Guid userId);

        List<SimpleUser> GetUsersInDept(Guid deptId);

        List<UserProfile> GetUserProfiles(string memberstring);

        SimpleUser GetSimpleUserById(Guid userId);
        List<SimpleUser> GetAllUserInfo();

        List<SimpleUser> GetSimpleUserInfos(string memberstring);

        List<Dept> GetAllDepts();
        void CreateDept(string deptName, Guid CurrentUserId);
        void RemoveDept(Guid deptId, Guid CurrentUserId);

        List<Position> GetPostions();

        Dept GetDeptById(Guid id);

        void UpdateHeadIcon(Guid userId, byte[] iconData, string iconType);

        UserHeadImage GetHeadIcon(Guid userId);

        Guid? CreateNewUser(UserProfile newUserProfile, string newPassword);

        void UpdateUserProfile(UserProfile userProfile);

        void ChangePassword(Guid userId, string oldPassword, string newPassword);
        #endregion

        #region [ Groups && Memberstrings ]

        List<SimpleUser> GetAllUsersByMemberString(string memberString);

        IDictionary<Guid, string> GetChildrenByMemberString(string memberString);

        Group GetGroupByName(string groupName);

        List<Group> GetAllSystemGroups();

        Group GetSystemGroup(string groupName);

        Group GetGroupById(Guid groupId);

        List<Group> GetGroups(string groupIdStrs = null);

        void UpdateProjectGroup(Guid projectId, string projectName, string memberstring);

        #endregion

        #region [ Feed Methods ]

        Guid SendFeed(
            string templateName, 
            string feedData, 
            string memberString, 
            Guid? senderId = null, 
            string ignoreUsers = null, 
            bool isAvailable = true,
            bool isDisplayInMainPanel = true);

        void UpdatePersonalFeedData(Guid feedId, string memberstring, string feedDataEx);

        void UpdatePersonalFeedType(Guid feedId, string memberstring, string feedTypeStr);

        void UpdateFeedRecipients(Guid feedId, string memberstring);


        void SetFeedRecord(Guid identity, string templateName, string memberstring, Guid feedId, string ignoreUsers);

        string GetFeedRecord(Guid identity, string templateName, string userId);
        

        void UpdateFeedData(Guid updateFeedId, string newFeedData);

        void UpdateFeedsData(string updateFeeds, string updateFeedData);


        void SetFeedIsAvailable(Guid feedId, string memberString, bool isAvailable);

        void SetFeedsIsAvailable(string feedIdStrs, string memberString, bool isAvailable);


        void SetFeedIsRead(Guid feedId, string memberString, bool isRead);

        void SetFeedsIsRead(string feedIdStrs, string memberString, bool isRead);
        #endregion

        #region [ Permissions ]
        /// <summary>
        /// 用户是否拥有权限
        /// </summary>
        /// <param name="permissionStr">用户权限字符串</param>
        /// <param name="userId">用户Id</param>
        /// <returns></returns>

        bool UserHasPermission(string permissionStr, Guid userId);


        /// <summary>
        /// 用户组是否拥有权限
        /// </summary>
        /// <param name="permissionStr">用户权限字符串</param>
        /// <param name="userId">用户组Id</param>
        /// <returns></returns>

        bool GroupHasPermission(string permissionStr, Guid groupId);
        #endregion

        #region [Device Token]

        void SaveDeviceToken(Guid userId, string deviceToken);
        string GetDeviceToken(Guid userId);
        #endregion

        void CreatePosition(string positionName, Guid CurrentUserId);
        void RemovePosition(Guid positionId, Guid CurrentUserId);
    }
}
